<?php
/**
 * Created by PhpStorm.
 * User: 17628
 * Date: 2021-11-03
 * Time: 15:12
 */

namespace app\admin\validate;


use think\Validate;

class Certification extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'real_name' => 'require',
        'mobile' => 'require|max:11|/^1[3-8]{1}[0-9]{9}$/',
        'idcard' => 'require|min:18|max:18',
    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'real_name.require' => '请输入姓名',
        'mobile.require' => '请输入手机号',
        'mobile.max' => '手机号码不能超过11位',
//        'mobile./^1[3-8]{1}[0-9]{9}$/' => '手机号码格式不正确',
        'idcard.require' => '请输入身份证号',
        'idcard.min' => '身份证不能低于过18位',
        'idcard.max' => '身份证不能超过18位',
        'idcard' => '身份证号格式不正确',
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'add' => [],
        'edit' => ['mobile', 'real_name', 'idcard'],
        'check' => ['mobile', 'real_name', 'idcard'],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'real_name' => __('Real_name'),
            'mobile' => __('Mobile'),
            'idcard' => __('Idcard'),
        ];
        parent::__construct($rules, $message, $field);
    }

}